/*  mudmap - A tool to create and organize user side maps for MUD games
 *  Copyright (C) 2012  Neop (aka moemneop, email: mneop@web.de)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, see <http://www.gnu.org/licenses/>.
 */

/*  File description
 *
 *  Organizes multiple worlds and the creation of a new world
 */

#pragma once

#include <fstream>
#include <iostream>
#include <list>

#include <gtk/gtk.h>
#include <glib-2.0/glib/gi18n.h>

#include "world.h"
#include "properties.h"

using namespace std;

typedef void (*button_func)(GtkToolButton *toolbutton, gpointer user_data);

class worldmgr{
    public:
        static worldmgr *get_instance();
        virtual ~worldmgr();

        void load_world(string file, bool force = false);
        shared_ptr<world> get_world(string file);
        void create_world(string name, string file);

        void add_available(string name, string file);
        void remove_available(string name);
        void read_available();
        void write_available();
        vector<pair<string, string> > get_available();

        GtkWidget *get_content();
        GtkWidget *get_label();
        void update_dialog(button_func overview_open_world_func = nullptr);

        void set_worlds_file(string);
        string get_worlds_file();
    private:
        worldmgr();
        static worldmgr *instance;

        GtkWidget *content, *vbox_worlds, *scroll_available_worlds;

        static void overview_delete_world_func(GtkToolButton *toolbutton, gpointer user_data);
        button_func overview_open_world_func;

        map<string, shared_ptr<world> > worlds;
        /// bekannte Welten (name / file)
        map<string, string> available_worlds;
};
